package csdn;
//继承Thread，创建线程类
class MyThread extends Thread{
    @Override
    public void run() {
        for (int i = 0; i < 3; i++) {
            try {
                System.out.println("hello Thread");
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
public class D1 {
    public static void main(String[] args) throws InterruptedException {
        //创建MyThread类的实例
        MyThread thread = new MyThread();
        //调用start方法创建线程
        thread.start();
        for (int i = 0; i < 3; i++) {
            System.out.println("hello main");
            Thread.sleep(1000);
        }
    }
}
